<?php
/* SVN FILE: $Id: taxes.php 222 2009-09-16 20:07:22Z supersmashbrothers $ */
/**
* ibMarket 2
* IP.Board 3.0
* Viewing collected taxes
*
* @author $Author: supersmashbrothers $
* @copyright $Copyright$
* @version $Revision: 222 $
* @lastrevision $Date: 2009-09-16 20:07:22 +0000 (Wed, 16 Sep 2009) $
* @modifiedby $LastChangedBy: supersmashbrothers $
* @lastmodified $LastChangedDate: 2009-09-16 20:07:22 +0000 (Wed, 16 Sep 2009) $
* @filesource $URL: http://ipb-ibmarket.googlecode.com/svn/ibmarket2/trunk/admin/applications_addon/other/ibmarket/modules_public/logs/taxes.php $
*/

class public_ibmarket_logs_taxes extends marketPublicCommand
{
	public function doExecute( ipsRegistry $registry )
	{
		if($this->memberData['member_id'] == 0 || $this->memberData['g_market_use'] == 0)
		{
			$this->registry->getClass('output')->showError('no_permission');
		}
		
		$this->request['st'] = max(intval($this->request['st']), 0);
		
		$logs = array();
		$this->DB->build(array(
								'select'	=> '*',
								'from'		=> 'market_tax_logs',
								'calcRows'	=> TRUE,
								'where'		=> "member_id=".$this->memberData['member_id']." AND amount != 0",
								'order'		=> 'l_time DESC',
								'limit'		=> array($this->request['st'], 25),
						)	);
		$q = $this->DB->execute();
		$total = $this->DB->fetchCalculatedRows();
		while($log = $this->DB->fetch($q))
		{
			$logs[] = $log;
		}
		
		$pages = $this->registry->output->generatePagination( array( 'totalItems'			=> $total,
																	 'itemsPerPage'			=> 25,
																	 'currentStartValue'	=> $this->request['st'],
																	 'baseUrl'				=> 'app=ibmarket&amp;module=logs&amp;section=taxes',
																	 'dotsSkip'				=> 5,
														)		);
		
		$content = $this->registry->getClass('output')->getTemplate('ibmarket')->collectedTaxes($logs, $pages);
		
		$template = $this->registry->getClass('output')->getTemplate('ibmarket')->ibmarketHTMLWrapper($content);
		
		$this->registry->getClass('output')->setTitle( $this->settings['market_name'] );
		$this->registry->getClass('output')->addContent( $template );
		
        $this->registry->getClass('output')->sendOutput();
	}
}